import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import './App.css'
import Login from './pages/Login';
import Tab from './pages/Tab'
import Read from './pages/Read'
import Edit from './pages/Edit'
import { connect } from 'react-redux'

const mapStateToProps = (state) => ({
  name: state.name
})

function App(props) {
  return (
    <Router>
      <Switch>
        <Route path="/" exact render={() => (
          props.name ? <Tab /> : <Login />
        )} />
        <Route path="/read" component={Read} />
        <Route path="/edit" component={Edit} />
      </Switch>
    </Router>
  );
}

export default connect(mapStateToProps, null)(App);
